package cn.SiFuLan.controls;

import cn.SiFuLan.dao.IskuDao;
import cn.SiFuLan.dao.impl.skuDaoImapl;
import cn.SiFuLan.entity.skuEntity;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

@WebServlet(urlPatterns = "/admin/skuupdate1.shtml")
public class skuupdateServlt1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=request.getParameter("skuid");
        String spuid=request.getParameter("spuid");
        String title=request.getParameter("title");
        String color=request.getParameter("color");
        String gg=request.getParameter("gg");
        String jq=request.getParameter("jq");
        String sf=request.getParameter("sf");
        IskuDao iskuDao=new skuDaoImapl();
        skuEntity sku=new skuEntity();
        sku.setTitle(title);
        sku.setColor(color);
        sku.setSpecification(gg);
        sku.setPrive(jq);
        if(sf!=null && !sf.equals("")){
            sku.setValid(Integer.parseInt(sf));
        }
        if(spuid!=null && !spuid.equals("")){
            sku.setSpu_id(Integer.parseInt(spuid));
        }
        sku.setUpdateTime(new Date());
        if(id!=null && !id.equals("")){
            sku.setSku_id(Integer.parseInt(id));
        }
        if(iskuDao.update(sku)){
            response.sendRedirect("skuindex.do");
        }
    }
}
